package com.ophiux.thread;

import java.net.Socket;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class test {

    public static void main(String[] args) {
		Thread01 thread01 = new Thread01();
		thread01.start();

		Thread02 thread02 = new Thread02();
		thread02.run();

//		new Thread(() -> {
//			System.out.println("启动一个线程");
//		}).start();


//		new Thread(new Runnable() {
//			@Override
//			public void run() {
//				System.out.println("启动2个线程");
//			}
//		}).start();


        FutureTask<Integer> ft = new FutureTask<>(new Thread03());
        for (int i = 0; i < 100; i++) {
            System.out.println(Thread.currentThread().getName() + " 的循环变量i的值" + i);
            if (i == 20) {
                new Thread(ft, "有返回值的线程").start();
            }
        }
        try {
            System.out.println("子线程的返回值：" + ft.get());
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }

    }
}
